import {Component} from 'react'
import LoginForm from './LoginForm';
import Form from './Form';
import List from './List';
import '../assets/css/style.css'

class  Login extends Component {
    constructor(){

        super();
        this.state={
            msg:"",
            count:200,
            title:"你好",
            userInfo:{name:"张三",age:20}
        }
    }
    update(){

        // this.setState({title:"hello"});
        this.setState({title:"hello",userInfo:{...this.state.userInfo,name:"李四"}})

        // this.setState((preState)=>{
 
        //     return {
        //         title:"hello",
        //         userInfo:{name:"李四"}
        //     }
        // },()=>{
        //     console.log(this.state.title);

        // })

    }

    getData=(val)=>{
    
        

        
        this.setState({msg:val})

    }


    render(){

        return (
            <div>
                <List></List>
                {this.state.msg}
                <div>
                    ---------
                </div>
                <Form></Form>

                <LoginForm getData={this.getData} age={20} userInfo={this.state.userInfo} id={this.state.count}></LoginForm>

                {this.state.title}

                {this.state.userInfo.name}{this.state.userInfo.age}
 

                <button onClick={()=>this.update()}>修改</button>


            </div>
        )

    }
    
}
export default Login;